package comWorld.blog.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import comWorld.blog.BlogInfo;
import comWorld.blog.BlogInfos;

/**
 * Servlet implementation class DraftsPageInit
 */
@WebServlet("/admin/drafts")
public class DraftsPageInit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DraftsPageInit() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		BlogInfos draftInfos = (BlogInfos) session.getAttribute("draftInfos");
		List<BlogInfo> drafts = draftInfos.getBlogs();
		request.setAttribute("drafts", drafts);
		request.getRequestDispatcher("/blog/drafts.jsp").forward(request, response);
	}

}
